package edu.hit;

import edu.hit.Utils.Utils;

import java.net.InetSocketAddress;
import java.util.List;

public class Configuration {

    public enum Role{
        master,slave

    }

    public static String getMaster_replid() {
        return master_replid;
    }

    public static int getMaster_repl_offset() {
        return master_repl_offset;
    }

    public static boolean isIsReplica() {
        return isReplica;
    }

    private static String master_replid = "8371b4fb1155b71f4a04d3e1bc3e18c4a990aeeb";

    private static int master_repl_offset = 0;

    private static boolean isReplica = false;

    private static Role role = Role.master;

    private static InetSocketAddress master;

    //private Map<String,String>

//    public edu.hit.Configuration (){
//        this.role = Role.master;
//    }

    public static void configureReplica(InetSocketAddress masterAddr ){
        master = masterAddr;
        isReplica = true;
        role = Role.slave;
    }



    public static String getRole(){
        return role.toString();
    }

    public static InetSocketAddress getMaster(){
        return master;
    }



    public static String getInfo(String section){
        return switch (section){
            case "replication" -> Utils.StringConstructor(List.of(
                    "role:" + role.toString()
                    ,"master_replid:" + master_replid
                    ,"master_repl_offset:" + master_repl_offset
                    )) ;


            default -> throw new IllegalStateException("Unexpected value: " + section);
        };


    }

    public static String getAllInfo(){
        return null;
    }
}
